package demo1;
import java.util.Scanner;

/**
 * 测试类
 */
public class Test {
    public static void main(String[] args){

        Scanner in = new Scanner(System.in);
        System.out.println("欢迎来到特种部队！");
        System.out.println("********战前准备********");
        Player p1 =new Player();
        System.out.print("请录入昵称：");
        String name = in.next();
        System.out.print("1.雨潇生 2.醉清风 3.如梦令 请选择对战玩家（1~3）：");
        int num = in.nextInt();
        switch(num){
            case 1:
                p1 = new Player("雨潇生",100);
                break;
            case 2:
                p1 = new Player("醉清风",100);
                break;
            case 3:
                p1 = new Player("如梦令",100);
                break;
            default:
                System.out.println("您的输入有误！");
                break;
        }
        Player p2 = new Player(name,100);

        Gun gun1 = new Gun();
        Gun gun2 = new Gun();
        //玩家持枪
        p1.holdGun(gun1);
        p2.holdGun(gun2);
        //装配弹夹、子弹
        Clip clip1 = new Clip();
        Clip clip2 = new Clip();
        for(int i = 1;i <= 30;i++){
            clip1.pushBullet(new Bullet());
            clip2.pushBullet(new Bullet());
        }
        p1.loadClip(clip1);
        p2.loadClip(clip2);
        //显示信息
        p1.showPlayer();
        p2.showPlayer();
        int i = 0;  //回合数
        System.out.println("********开始对战********");
        boolean isExit = false;   //是否退出游戏
        while(true){
            System.out.println("---第"+(i+1)+"回合---");
            i++;
            p1.shootEnemy(p2);
            if(p2.getBlood()==0) {
                System.out.println(p1.getName()+"获胜！");
                System.out.println("退出江湖!");
                return;
            }
            p2.shootEnemy(p1);
            if(p1.getBlood()==0) {
                System.out.println(p2.getName()+"获胜！");
                System.out.println("退出江湖!");
                return;
            }
            System.out.println();
            p1.showPlayer();
            p2.showPlayer();
            System.out.print("是否继续对战（输入y继续，其他键退出）？");
            if(!(in.next().equals("y"))){
                System.out.println("退出江湖!");
                return;
            }
        }
    }
}
